As well known, program link include static link and dynamic link. When the static link is adopted, the address of an application program is determinate in a compile phase. If multiple application programs invoke functions in a function library currently, the number of function libraries needing to be copied into a memory is the same as the number of the application programs, which will waste the space of the memory. In the dynamic link, the functions in the function library are located through an import library. The import library only stores a description of an invoking relation between functions, does not store actual codes, and thus can save the space of the memory.
Currently, in an embedded product such as a mobile telephone, the dynamic link of a program has been implemented by using an Executable and Linking Format (ELF) mode, referring to FIG. 1.
FIG. 1 is a schematic diagram of dynamically linking a program by using an ELF mode in the prior art.
As shown in FIG. 1, when the dynamic link of the program is implemented by using the ELF mode, the application program is compiled into an ELF file firstly, then function relocation and variable relocation are performed for the ELF file by using an ELF LOADER program, afterwards the ELF file for which the relocation has been performed is loaded into an embedded Operation System (OS), and finally the embedded operation system links functions and variables according to the positions of the functions and variables for which the relocation has been performed, so as to implement the dynamic link of the program.
When the dynamic link of the program is implemented by using the ELF mode, the ELF LOADER program plays an important role, which is used to relocate the addresses of functions and variables in the application program with addresses in the embedded operation system. Specifically, the ELF LOADER program extracts available information from the ELF file, calculate the addresses used after the relocation for functions and variables in the ELF file, and then perform relocation for the functions and variables according to the addresses.
As can be seen, when the dynamic link of the program is implemented by using the ELF mode, since it is needed to extract available information from the ELF file and perform processing for the available information, the speed of dynamically linking the program is slow and calculating resources are wasted.